<?php

namespace Fize\Third\FuTu;

/**
 * 富途行情及交易接口
 * https://openapi.futunn.com/futu-api-doc/quote/overview.html
 */
class FuTu extends Common
{

    /**
     * 获取股票快照
     * @param array $codes 股票代码
     * @return array
     */
    public function Qot_GetSecuritySnapshot(array $codes): array
    {
        $this->initConnect();
        $securityList = [];
        foreach ($codes as $code) {
            $code = self::getShortCode((string)$code);
            $securityList[] = [
                'market' => self::getMarket($code),
                'code'   => $code,
            ];
        }

        $C2S = [
            'securityList' => $securityList,
        ];
        $ret = $this->send(3203, $C2S);
        return $ret['snapshotList'];
    }

    /**
     * 获取指定品种的市场状态
     * @param array $codes 股票代码
     * @return array
     */
    public function Qot_GetMarketState(array $codes): array
    {
        $this->initConnect();

        $securityList = [];
        foreach ($codes as $code) {
            $code = self::getShortCode((string)$code);
            $securityList[] = [
                'market' => self::getMarket($code),
                'code'   => $code,
            ];
        }
        $C2S = [
            'securityList' => $securityList,
        ];
        $ret = $this->send(3223, $C2S);
        return (array)$ret['marketInfoList'];
    }
}
